﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _11_param_可变参数
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] s1 = { 1, 2, 3, 4, 6, 7 };
            CalcScore("zhangsan",s1);
            CalcScore("luzhi", 12, 3, 4, 5, 6);
            Console.ReadKey();
        }
        //params 必须将params放置在形参的最后
        public static void CalcScore(string name, params int[] score)
        {
            //params  将实参列表中跟可变参数数组类型一致的类型都处理成一致的元素
            int sum = 0;
            for (int i = 0; i < score.Length; ++i)
            {
                sum += score[i];
            }
            Console.WriteLine("{0}的总成绩是{1}", name, sum);
        }
    }
}
